package com.tms.pidan.controller;

import com.alibaba.fastjson.JSON;
import com.tms.pidan.common.utils.Result;
import com.tms.pidan.entity.LocationEntity;
import com.tms.pidan.service.KafkaSender;
import io.swagger.annotations.Api;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/netty")
@Api(tags = "车辆轨迹服务")
public class NettyController {

    /**
     * 司机上报位置
     * @param locationEntity
     * @return
     */

    @PostMapping("/push")
    public Result push(@RequestBody LocationEntity locationEntity){
        String message=JSON.toJSONString(locationEntity);
        /**
         * 将车辆轨迹信息发送给kafka队列
         */
        KafkaSender.send(KafkaSender.MSG_TOPIC,message);
        return Result.ok("发送成功");
    }
}
